<template>
  <div>
    <h2 ref='MyH2'>学习好</h2>
    <MySon ref='Son'></MySon>
    <button @click='fn'>修改</button>
  </div>
</template>

<script>
import MySon from "./components/MySon.vue";
export default {
  components: {
    MySon
  },
  data() {
    return {
     
    }
  },
  methods: {
    fn(){
      //获取元素
      this.$refs.MyH2.innerHTML ='哈哈哈哈'
      //获取子组件
     console.log( this.$refs.Son.msg);
     this.$refs.Son.saiHi()
    }
  },
}
</script>

<style scoped></style>